#include "../../server.hpp"

void OnConnected(const PtrConnection &conn){
    DEBUG_LOG("New Connection: %p", conn.get());
}
void OnClosed(const PtrConnection &conn)
{
    DEBUG_LOG("Connection: %p Closed", conn.get());
}
void OnMessage(const PtrConnection &conn, Buffer *buf){
    DEBUG_LOG("%s", buf->read_pos());
    buf->move_reader(buf->readable_size());
    std::string str = "hello cli";
    conn->Send(str.c_str(), str.size());
    // conn->ShutDown();
    // conn->EnableInactiveRelease(10);
}

int main(){
    TcpServer svr(8500);
    svr.SetThreadCount(2);
    svr.EnableInactiveRelease(10);
    svr.SetClosedCallback(OnClosed);
    svr.SetConnectedCallback(OnConnected);
    svr.SetMessageCallback(OnMessage);
    svr.Start();

    return 0;
}